

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="layout" content="main" />
    <title>${fieldValue(bean:courseInstance, field:'activityId')} - ${fieldValue(bean:courseInstance, field:'name')}</title>
  </head>
  <body>
    <div class="undernav">
      <span class="menuButton"><g:link class="list" action="list">${Inter.printOut('Course List',session.language)}</g:link></span>
      <span class="menuButton"><g:link class="create" action="create">${Inter.printOut('New Course',session.language)}</g:link></span>
      <!-- This is the help button. -->
<%  def help = Help.findByNameAndLanguage("course_show", session.language)
def helplink = createLink(action:'show', controller:'help', id: help.id )%>
      <a href="#" onClick="MyWindow=window.open('${helplink}','Help','width=350,height=450'); return false;">${Inter.printOut('Help',session.language)}</a>
      <!-- This is the end of the help button. -->
    </div>
    <div class="body" style="width:98%">
      <g:javascript src="jquery.livequery.js" />
      <g:javascript src="budget/editFigures.js" />
      <g:link class=" urlUpdateHours" controller="course" action="updateHours"></g:link>


      <g:if test="${flash.message}">
        <div class="message">${flash.message}</div>
      </g:if>
      <div style="width:100%;float:left;">
        <div class="courseDetails" style="width:50%; float:left; margin-top:15px;">
          <h2>${Inter.printOut('Course',session.language)}: ${fieldValue(bean:courseInstance, field:'name')}</h2>
          <table>
            <tbody>
              <tr class="prop">
                <td valign="top" class="name">${Inter.printOut('Course Code',session.language)}:</td>

                <td valign="top" class="value">${fieldValue(bean:courseInstance, field:'activityId')}</td>

              </tr>


              <tr class="prop">
                <td valign="top" class="name">${Inter.printOut('Description',session.language)}:</td>

                <td valign="top" class="value">${fieldValue(bean:courseInstance, field:'description')}</td>

              </tr>

              <tr class="prop">
                <td valign="top" class="name">${Inter.printOut('Level',session.language)}:</td>

                <td valign="top" class="value">${Inter.printOut(fieldValue(bean:courseInstance, field:'level'),session.language)}</td>

              </tr>

              <tr class="prop">
                <td valign="top" class="name">${Inter.printOut('Area',session.language)}:</td>

                <td valign="top" class="value"><g:link controller="area" action="show" id="${courseInstance?.area?.id}">${courseInstance?.area?.encodeAsHTML()}</g:link></td>

            </tr>

            <g:if test="${session?.container && Container.get(session?.container)?.hasTab('boardName') || !session?.container}">
            <tr class="prop">
                <td valign="top" class="name">${Inter.printOut('Board Name',session.language)}:</td>

                <td valign="top" class="value">${fieldValue(bean:courseInstance, field:'boardName')}</td>

            </tr>
            </g:if>

            </tbody>
          </table>
          <div class="buttons">
            <g:form>
              <input type="hidden" name="id" value="${courseInstance?.id}" />
              <span class="button"><g:actionSubmit class="edit" value="${Inter.printOut('Edit',session.language)}"  action="Edit"/></span>
              <span class="button"><g:actionSubmit class="delete" onclick="return confirm('${Inter.printOut('Sure',session.language)}');" value="${Inter.printOut('Delete',session.language)}" action="Delete" /></span>
              <span class="button"><g:actionSubmit class="addNote" value="${Inter.printOut('Add note',session.language)}" action="addNote" /></span>
            </g:form>
          </div>
        </div>

        <g:if test="${session?.container && Container.get(session?.container)?.hasTab('Schedule') || !session?.container}">
        <div class="courseSchedules" style="width:45%; float:left; margin-left:5%">
          <br/><h2>${Inter.printOut('Schedules',session.language)}</h2>
          <table>
            <tbody>
              <tr>
                <th>${Inter.printOut('Date',session.language)}</th>
                <th>${Inter.printOut('Start Hour',session.language)}</th>
                <th>${Inter.printOut('End Hour',session.language)}</th>
                <th>${Inter.printOut('Responsible',session.language)}</th>

              </tr>
            <g:each var="m" in="${courseInstance.schedules}">
              <tr>
                <td><g:link action="show" controller="schedule" id="${m?.id}">${m?.day()}</g:link></td>
                <td><g:link action="show" controller="schedule" id="${m?.id}">${m?.startHours()}</g:link></td>
                <td><g:link action="show" controller="schedule" id="${m?.id}">${m?.endHours()}</g:link></td>
                <td><g:link action="show" controller="schedule" id="${m?.id}">${m?.responsible}</g:link></td>
              </tr>
            </g:each>
            </tbody>
          </table>
          <div class="buttons">
            <g:form>
              <input type="hidden" name="id" value="${courseInstance?.id}" />
              <span class="button"><g:actionSubmit class="add_schedule"  value="${Inter.printOut('Add',session.language)}" action="add_schedule" /></span>
              <g:if test="${courseInstance.schedules.size() > 0}">
                <span class="button"><g:actionSubmit action ="delete_schedule" class="delete_schedule" value="${Inter.printOut('Delete',session.language)}" /></span>
              </g:if>
            </g:form>
          </div>
        </div>
      </g:if>

      </div>
      <div style="float:left ;width:100%">
        <div class="courseTeachers" style="float:left;width:50%;margin-top:15px;">
          <h2>${Inter.printOut('Teachers',session.language)}</h2>
          <table>
            <tbody>
              <tr>
                <th>${Inter.printOut('First Name',session.language)}</th>
                <th>${Inter.printOut('Last Name',session.language)}</th>
                <th>${Inter.printOut('salary',session.language)}</th>
                <th>${Inter.printOut('Hours',session.language)} (h)</th>
                <th>${Inter.printOut('percentage work',session.language)} (%)</th>
              </tr>
              <%
              Float fixedCost=0
              %>
            <g:each var="m" in="${courseInstance.amountOfHour}">
              <tr>
                <td><g:link action="show" controller="employee" id="${m?.id}">${m?.member?.firstName} </g:link></td>
                <td><g:link action="show" controller="employee" id="${m?.id}">${m?.member?.lastName} </g:link></td>
                <td><g:link action="show" controller="employee" id="${m?.id}">${m?.member?.salary} </g:link></td>
                <td><span class="hoursFigures" id="updateHours" title="${m?.id}"> ${m?.hours}<img alt="edit" style="vertical-align:text-bottom;" src="${resource(dir:'images/skin',file:'pencil.png')}"/></span></td>
                <td><span class="hoursFigures" id="updatePercentageOfCourses" title="${m?.id}"><g:formatNumber number="${(m?.hours/m.member.hoursForAge())*100}" format="###"/><img alt="edit" style="vertical-align:text-bottom;" src="${resource(dir:'images/skin',file:'pencil.png')}"/></span></td>
              </tr>

            <%
            fixedCost += (m?.hours/m.member.hoursForAge()) * m?.member?.salary
            %>
            </g:each>
            </tbody>
          </table>
          <div class="buttons">
            <g:form>
              <input type="hidden" name="id" value="${courseInstance?.id}" />
              <span class="button"><g:actionSubmit class="add_employee" value="${Inter.printOut('Add Employee',session.language)}" action ="add_employee" /></span>
              <g:if test="${numberOfEmployees > 0}">
                <span class="button"><g:actionSubmit class="delete_employee" value="${Inter.printOut('Remove Employee',session.language)}" action ="delete_employee" /></span>
              </g:if>
            </g:form>
          </div>
          <br/>
          <h2>${Inter.printOut('Total fixed cost',session.language)}:  ${fixedCost}</h2>
          <br/>
        </div>

        
        <div style="float:left; width:45%; margin-left:5%; margin-top:14px;">
          <h2>${Inter.printOut('Notes',session.language)}</h2>
          <table>
            <thead>
                <tr>
                  <g:sortableColumn property="note" title="${Inter.printOut('Note',session.language)}" />
                  <g:sortableColumn property="year" title="${Inter.printOut('Year',session.language)}" />
                </tr>
            </thead>
            <tbody>
            <g:each in="${courseInstance.notes}" status="i" var="noteInstance">
                <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
                  <td><g:link action="show" controller="note" id="${noteInstance.id}">${noteInstance.note}</g:link></td>
                  <td><g:link action="show" controller="note" id="${noteInstance.id}">${noteInstance.year}</g:link></td>
                </tr>
            </g:each>
            </tbody>
          </table>
        </div>
      </div>
      
      
    </div>
  </body>
</html>
